home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr05 / xnot12a.zip / DEF.H < prev    next >
C/C++ Source or Header  |  1993-06-10  |  11KB  |  351 lines

  1. /*
  2.  * This file is the general header file for all parts
  3.  * of the MicroEMACS display editor. It contains all of the
  4.  * general definitions and macros. It also contains some
  5.  * conditional compilation flags. All of the per-system and
  6.  * per-terminal definitions are in special header files.
  7.  * The most common reason to edit this file would be to zap
  8.  * the definition of CVMVAS or BACKUP.
  9.  */
  10. #include    "sysdef.h"        /* Order is critical.        */
  11. #include    "ttydef.h"
  12. #include    "chrdef.h"
  13.  
  14. #ifdef JAM
  15. # include <time.h>
  16. # define AsyncUpdate()  noop()
  17. #endif
  18.  
  19. /*
  20.  * If your system and/or compiler does not support the "void" type
  21.  * then define NO_VOID_TYPE in sysdef.h.  In the absence of some
  22.  * other definition for VOID, the default in that case will be to
  23.  * turn it into an int, which works with most compilers that don't
  24.  * support void.  In the absence of any definition of VOID or
  25.  * NO_VOID_TYPE, the default is to assume void is supported, which
  26.  * should be the case for most modern C compilers.
  27.  */
  28.  
  29. #ifdef NO_VOID_TYPE
  30. #  undef VOID
  31. #  define VOID int            /* Default for no void is int */
  32. #else
  33. #ifndef VOID
  34. #  define VOID void            /* Just use normal void */
  35. #endif /* VOID */
  36. #endif /* NO_VOID_TYPE */
  37.  
  38.  
  39. typedef int (*PF)();            /* generaly useful type */
  40.  
  41. /*
  42.  * Table sizes, etc.
  43.  */
  44. #ifdef FAT
  45. # define NFILEN    256            /* Length, file name.        */
  46. # define NBUFN   24            /* Length, buffer name.        */
  47. #else
  48. # define NFILEN 512            /* Length, file name.        */
  49. # define NBUFN   30            /* Length, buffer name.        */
  50. #endif
  51.  
  52. #define NLINE    512            /* Length, line.        */
  53. #define PBMODES 4            /* modes per buffer        */
  54. #define NKBDM    256            /* Length, keyboard macro.    */
  55. #define NPAT    80            /* Length, pattern.        */
  56. #define HUGEN    1000            /* A rather large number.    */
  57. #define NSRCH    128            /* Undoable search commands.    */
  58. #define NXNAME    128            /* Length, extended command.    */
  59. #define NKNAME    128            /* Length, key names        */
  60. /*
  61.  * Universal.
  62.  */
  63. #ifndef TRUE
  64. # define FALSE    0            /* False, no, bad, etc.        */
  65. # define TRUE    1            /* True, yes, good, etc.    */
  66. #endif
  67. #define ABORT    2            /* Death, ^G, abort, etc.    */
  68.  
  69. #define KPROMPT 2            /* keyboard prompt        */
  70.  
  71. /*
  72.  * These flag bits keep track of
  73.  * some aspects of the last command. The CFCPCN
  74.  * flag controls goal column setting. The CFKILL
  75.  * flag controls the clearing versus appending
  76.  * of data in the kill buffer.
  77.  */
  78. #define CFCPCN    0x0001            /* Last command was C-P, C-N    */
  79. #define CFKILL    0x0002            /* Last command was a kill    */
  80. #define CFINS    0x0004            /* Last command was self-insert */
  81.  
  82. #define CFKILLB 0x0008                  /* killbuffer */
  83. #define CFNEWF  0x0010                  /* new file */
  84. #define CFNEWB  0x0020                  /* use buffer */
  85. #define CFNEWC  0x0020                  /* use buffer */
  86.  
  87. /*
  88.  * File I/O.
  89.  */
  90. #define FIOSUC    0            /* Success.            */
  91. #define FIOFNF    1            /* File not found.        */
  92. #define FIOEOF    2            /* End of file.            */
  93. #define FIOERR    3            /* Error.            */
  94. #define FIOLONG 4            /* long line partially read    */
  95.  
  96. /*
  97.  * Directory I/O.
  98.  */
  99. #define DIOSUC    0            /* Success.            */
  100. #define DIOEOF    1            /* End of file.            */
  101. #define DIOERR    2            /* Error.            */
  102.  
  103. /*
  104.  * Display colors.
  105.  */
  106. #ifndef JAM  /* see jam.h */
  107. # define CNONE    0            /* Unknown color.        */
  108. # define CTEXT    1            /* Text color.            */
  109. # define CMODE    2            /* Mode line color.        */
  110. #endif
  111.  
  112. /* Flags for keyboard involked functions */
  113.  
  114. #define FFUNIV        1        /* universal argument        */
  115. #define FFNEGARG    2        /* negitive only argument    */
  116. #define FFOTHARG    4        /* other argument        */
  117. #define FFARG        7        /* any argument            */
  118. #define FFRAND        8        /* Called by other function    */
  119.  
  120. /*
  121.  * Flags for "eread".
  122.  */
  123. #define EFFUNC    0x0001            /* Autocomplete functions.    */
  124. #define EFBUF    0x0002            /* Autocomplete buffers.    */
  125. #define EFFILE    0x0004            /* " files (maybe someday)    */
  126. #define EFAUTO    0x0007            /* Some autocompletion on    */
  127. #define EFNEW    0x0008            /* New prompt.            */
  128. #define EFCR    0x0010            /* Echo CR at end; last read.    */
  129.  
  130. /*
  131.  * Flags for "ldelete"/"kinsert"
  132.  */
  133.  
  134. #define KNONE    0
  135. #define KFORW    1
  136. #define KBACK    2
  137.  
  138. /*
  139.  * All text is kept in circularly linked
  140.  * lists of "LINE" structures. These begin at the
  141.  * header line (which is the blank line beyond the
  142.  * end of the buffer). This line is pointed to by
  143.  * the "BUFFER". Each line contains the number of
  144.  * bytes in the line (the "used" size), the size
  145.  * of the text array, and the text. The end of line
  146.  * is not stored as a byte; it's implied. Future
  147.  * additions will include update hints, and a
  148.  * list of marks into the line.
  149.  *
  150.  */
  151. typedef struct    line {
  152.     struct    line *l_fp;        /* Link to the next line    */
  153.     struct    line *l_bp;        /* Link to the previous line    */
  154.     short    l_size;            /* Allocated size        */
  155.     short    l_used;            /* Used size            */
  156.         unsigned short l_flag;        /* lines flags             */
  157. #ifndef ZEROARRAY
  158.     char    l_text[1];        /* A bunch of characters.    */
  159. #else
  160.     char    l_text[];        /* A bunch of characters.    */
  161. #endif
  162. }    LINE;
  163.  
  164. #define LFCHANGE 0x01            /* means line was touched */
  165. /*
  166.  * The rationale behind these macros is that you
  167.  * could (with some editing, like changing the type of a line
  168.  * link from a "LINE *" to a "REFLINE", and fixing the commands
  169.  * like file reading that break the rules) change the actual
  170.  * storage representation of lines to use something fancy on
  171.  * machines with small address spaces.
  172.  */
  173. #define lforw(lp)    ((lp)->l_fp)
  174. #define lback(lp)    ((lp)->l_bp)
  175. #define lgetc(lp, n)    (CHARMASK((lp)->l_text[(n)]))
  176. #define lputc(lp, n, c) ((lp)->l_text[(n)]=(c))
  177. #define llength(lp)    ((lp)->l_used)
  178. #define ltext(lp)    ((lp)->l_text)
  179.  
  180.  
  181. /*
  182.  * All repeated structures are kept as linked lists of structures.
  183.  * All of these start with a LIST structure (except lines, which
  184.  * have their own abstraction). This will allow for
  185.  * later conversion to generic list manipulation routines should
  186.  * I decide to do that. It does mean that there are four extra
  187.  * bytes per window. I feel that this is an acceptable price,
  188.  * considering that there are usually only one or two windows.
  189.  */
  190. typedef struct list {
  191.     union {
  192.         struct ewindow    *l_wp;
  193.         struct buffer    *x_bp;    /* l_bp is used by LINE */
  194.         struct list    *l_nxt;
  195.     } l_p;
  196.     char    *l_name;
  197. } LIST;
  198. /*
  199.  * Usual hack - to keep from uglifying the code with lotsa
  200.  * references through the union, we #define something for it.
  201.  */
  202. #define l_next    l_p.l_nxt
  203.  
  204. /*
  205.  * There is a window structure allocated for
  206.  * every active display window. The windows are kept in a
  207.  * big list, in top to bottom screen order, with the listhead at
  208.  * "wheadp". Each window contains its own values of dot and mark.
  209.  * The flag field contains some bits that are set by commands
  210.  * to guide redisplay; although this is a bit of a compromise in
  211.  * terms of decoupling, the full blown redisplay is just too
  212.  * expensive to run for every input character.
  213.  */
  214. typedef struct    ewindow {
  215.     LIST    w_list;            /* List header               */
  216.     struct buffer *w_bufp;        /* Buffer displayed in window    */
  217.     LINE   *w_linep;        /* Top line in the window    */
  218.     LINE   *w_dotp;            /* Line containing "."        */
  219.     LINE   *w_markp;        /* Line containing "mark"    */
  220.     int    w_doto;            /* Byte offset for "."        */
  221.     int    w_marko;        /* Byte offset for "mark"    */
  222.     int    w_toprow;        /* Origin 0 top row of window    */
  223.     int    w_ntrows;        /* # of rows of text in window    */
  224.     int    w_force;        /* If NZ, forcing row.        */
  225.     int    w_flag;            /* Flags.            */
  226. }    EWINDOW;
  227.  
  228. #define w_wndp    w_list.l_p.l_wp
  229. #define w_name    w_list.l_name
  230.  
  231. /*
  232.  * Window flags are set by command processors to
  233.  * tell the display system what has happened to the buffer
  234.  * mapped by the window. Setting "WFHARD" is always a safe thing
  235.  * to do, but it may do more work than is necessary. Always try
  236.  * to set the simplest action that achieves the required update.
  237.  * Because commands set bits in the "w_flag", update will see
  238.  * all change flags, and do the most general one.
  239.  */
  240. #define WFFORCE 0x01            /* Force reframe.        */
  241. #define WFMOVE    0x02            /* Movement from line to line.    */
  242. #define WFEDIT    0x04            /* Editing within a line.    */
  243. #define WFHARD    0x08            /* Better to a full display.    */
  244. #define WFMODE    0x10            /* Update mode line.        */
  245.  
  246. /*
  247.  * Text is kept in buffers. A buffer header, described
  248.  * below, exists for every buffer in the system. The buffers are
  249.  * kept in a big list, so that commands that search for a buffer by
  250.  * name can find the buffer header. There is a safe store for the
  251.  * dot and mark in the header, but this is only valid if the buffer
  252.  * is not being displayed (that is, if "b_nwnd" is 0). The text for
  253.  * the buffer is kept in a circularly linked list of lines, with
  254.  * a pointer to the header line in "b_linep".
  255.  */
  256. typedef struct    buffer {
  257.     LIST    b_list;            /* buffer list pointer        */
  258.     struct buffer *b_altb;        /* Link to alternate buffer    */
  259.     LINE *b_dotp;            /* Link to "." LINE structure    */
  260.     LINE *b_markp;            /* ditto for mark        */
  261.     LINE *b_linep;            /* Link to the header LINE    */
  262.     struct    MAPS_S *b_modes[PBMODES]; /* buffer modes        */
  263.     int    b_doto;            /* Offset of "." in above LINE    */
  264.     int    b_marko;        /* ditto for the "mark"        */
  265.     int    b_nmodes;        /* number of non-fundamental modes */
  266.     int    b_nwnd;            /* Count of windows on buffer    */
  267.     unsigned int    b_flag;        /* Flags            */
  268.     char    b_fname[NFILEN];    /* File name            */
  269. #ifdef JAM
  270.     time_t  b_time;                 /* disk file timestamp          */
  271.     char    b_iname[NFILEN];        /* inc backup name              */
  272.         void    *b_undo;                /* undo list */
  273. #endif
  274. #ifdef DOCRYPT
  275.         char b_key[NPAT+1];             /* encryption key */
  276. #endif
  277. }    BUFFER;
  278.  
  279. #define b_bufp    b_list.l_p.x_bp
  280. #define b_bname b_list.l_name
  281.  
  282. #define BFCHG    0x01        /* Changed.            */
  283. #define BFBAK    0x02        /* Need to make a backup.    */
  284.  
  285. #define BFNOTAB 0x04        /* no tab mode            */
  286.  
  287. #define BFOVERWRITE 0x08    /* overwrite mode        */
  288. #define BFINC    0x10           /* incremental change needed    */
  289. #define BFVIEW   0x20        /* readonly                     */
  290. #define BFC      0x40           /* C mode buffer                */
  291. #define BFCRYPT  0x80           /* encrypt this buffer on write/read */
  292. #define BFDIR    0x100          /* getcwd failed on this buffer */
  293. #define BFSAVED  0x200        /* incremental file created */
  294. #define BFREVERT 0x400        /* HACK - means buffer is dired mode,
  295.                                    buf buffer name is not useful in
  296.                                    constructing filenames */
  297. #define BFDELETE 0x800        /* delete file on kill buffer */
  298.  
  299. /*
  300.  * This structure holds the starting position
  301.  * (as a line/offset pair) and the number of characters in a
  302.  * region of a buffer. This makes passing the specification
  303.  * of a region around a little bit easier.
  304.  */
  305. typedef struct    {
  306.     LINE *r_linep;            /* Origin LINE address.        */
  307.     short    r_offset;        /* Origin LINE offset.        */
  308.     RSIZE    r_size;            /* Length in characters.    */
  309. }    REGION;
  310.  
  311. /*
  312.  * Externals.
  313.  */
  314. extern char    *homedir;
  315. extern    int    thisflag;
  316. extern    int    lastflag;
  317. extern    int    curgoal;
  318. extern    int    epresf;
  319. extern    int    sgarbf;
  320. extern    int    mode;
  321. extern EWINDOW    *curwp;
  322. extern BUFFER    *curbp;
  323. extern    EWINDOW    *wheadp;
  324. extern    BUFFER    *bheadp;
  325. extern    char    pat[];
  326. extern    int    nrow;
  327. extern    int    ncol;
  328. extern    int    ttrow;
  329. extern    int    ttcol;
  330. extern    int    tthue;
  331. extern    int    tceeol;
  332. extern    int    tcinsl;
  333. extern    int    tcdell;
  334. extern char    *wdir;
  335. extern BOOL    ealtmsg;
  336. extern BOOL    eprompting;
  337. extern BOOL    isearching;
  338. extern int     preload_;
  339. extern BOOL     showtouchedlines;
  340. extern BOOL    somemail;
  341.  
  342. /* macros vs functions
  343. */
  344. #define abs(a) ((a) > 0 ? (a) : (a) * -1)
  345. #define NullLine(lp) (((lp) == (LINE *)0) ? TRUE : FALSE)
  346.  
  347. /* generated from MSC
  348. */
  349. #include "proto.h"
  350.  
  351.